package com.tsinghua.server.base.service.impl;

import com.tsinghua.server.base.entity.Fxct1914ztzb;
import com.tsinghua.server.base.mapper.Fxct1914ztzbMapper;
import com.tsinghua.server.base.service.Fxct1914ztzbService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class Fxct1914ztzbServiceImpl implements Fxct1914ztzbService {
    @Resource
    Fxct1914ztzbMapper fxct1914ztzbMapper;

    @Override
    public List<Fxct1914ztzb> getProvinceNum() {
        List<Fxct1914ztzb> list = fxct1914ztzbMapper.getProvinceNum();
        return list;
    }

    @Override
    public List<Fxct1914ztzb> getBenefitBoard(Integer tagId) {
        List<Fxct1914ztzb> list = fxct1914ztzbMapper.getBenefitBoard(tagId);
        List returnList = new ArrayList();
        // 查询出省份列表
        List<String> provinces = fxct1914ztzbMapper.getProvinces();
        for (int i=0;i<provinces.size();i++) {
            boolean flag = false;
            for(int k=0;k<list.size();k++) {
                if(provinces.get(i).equals(list.get(k).getSfZt())) {
                    returnList.add(list.get(k).getSfztNum());
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                returnList.add(0);
            }
        }

        return returnList;
    }
}
